home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / thinkref / archive / THINKPascalUH2.1.sea / THINKPas Univ Hdr 2.1 / Interfaces / fenv.p < prev    next >
Text File  |  1995-09-12  |  10KB  |  264 lines

  1. { Converted with MPW2TPas Tuesday, September 12, 1995 6:03:55 PM }
  2. {
  3.      File:        fenv.p
  4.  
  5.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  6.                  All rights reserved.
  7.  
  8.      Version:    Universal Pascal, July 8, 1994 
  9.     
  10.     Note:        The following file was hand converted from fenv.h
  11.                 See fenv.h for more information and comments.
  12. }
  13.  
  14.  UNIT fenv;
  15.  INTERFACE
  16.  
  17.  
  18. {$IFC UNDEFINED __FENV__}
  19. {$SETC __FENV__ := 1}
  20.  
  21.   USES
  22.    ConditionalMacros, Types;
  23.  
  24.  
  25. {$IFC GENERATINGPOWERPC }
  26. TYPE
  27. {   fenv_t is a type for representing the entire floating-point
  28.       environment in a single object.                                         }
  29.  
  30.     fenv_t = LONGINT;
  31.  
  32. {   fexcept_t is a type for representing the floating-point
  33.       exception flag state collectively.                                      }
  34.  
  35.     fexcept_t = LONGINT;
  36.  
  37. CONST
  38. {    Definitions of floating-point exception macros                          }
  39.  
  40.     FE_INEXACT         = $02000000;       {     inexact              }
  41.     FE_DIVBYZERO       = $04000000;       {     divide-by-zero       }
  42.     FE_UNDERFLOW       = $08000000;       {     underflow            }
  43.     FE_OVERFLOW        = $10000000;       {     overflow             }
  44.     FE_INVALID         = $20000000;       {     invlalid             }
  45.  
  46. {   Definitions of rounding direction macros                                }
  47.  
  48.     FE_TONEAREST       = $00000000;
  49.     FE_TOWARDZERO      = $00000001;
  50.     FE_UPWARD          = $00000002;
  51.     FE_DOWNWARD        = $00000003;
  52.     
  53. {$ELSEC}
  54.  
  55. CONST
  56.     FE_TONEAREST       = $0000;
  57.     FE_UPWARD          = $0001;
  58.     FE_DOWNWARD        = $0002;
  59.     FE_TOWARDZERO      = $0003;
  60.     
  61. {   Definitions of rounding precision macros  (68K only)                    }
  62.  
  63.     FE_LDBLPREC        = $0000;
  64.     FE_DBLPREC         = $0001;
  65.     FE_FLTPREC         = $0002;
  66.  
  67.     {$IFC OPTION(mc68881) }
  68.     TYPE
  69.         fenv_t =     RECORD
  70.                         FPCR: LONGINT;
  71.                         FPSR: LONGINT;
  72.                     END;
  73.         fexcept_t = LONGINT;
  74.         
  75.     CONST
  76.         FE_INEXACT         = $00000008;  
  77.         FE_DIVBYZERO       = $00000010;     
  78.         FE_UNDERFLOW       = $00000020;    
  79.         FE_OVERFLOW        = $00000040;      
  80.         FE_INVALID         = $00000080;   
  81.     
  82.     {$ELSEC}
  83.     TYPE
  84.         fenv_t    = INTEGER;
  85.         fexcept_t = INTEGER;
  86.     CONST
  87.         FE_INVALID         = $0001;   
  88.         FE_UNDERFLOW       = $0002;    
  89.         FE_OVERFLOW        = $0004;      
  90.         FE_DIVBYZERO       = $0008;     
  91.         FE_INEXACT         = $0010;  
  92.     {$ENDC}
  93.     
  94. {$ENDC}
  95.  
  96.  
  97. {   The bitwise OR of all exception macros                                  }
  98.  
  99.     FE_ALL_EXCEPT  =   $3E000000;
  100.  
  101.  
  102. {   Definition of pointer to IEEE default environment object                }
  103. VAR
  104.     {$PUSH}
  105.     {$J+}
  106.     _FE_DFL_ENV: fenv_t;   {default environment object        }
  107.     {$POP}
  108.  
  109.  
  110.  
  111. {*****************************************************************************
  112. *     The following functions provide access to the exception flags.  The      *
  113. *     "int" input argument can be constructed by bitwise ORs of the exception  *
  114. *     macros: for example: FE_OVERFLOW | FE_INEXACT.                           *
  115. ******************************************************************************}
  116.  
  117. {******************************************************************************
  118. *     The function "feclearexcept" clears the supported exceptions represented *
  119. *     by its argument.                                                         *
  120. ******************************************************************************}
  121.  
  122. {PROCEDURE feclearexcept( excepts: LONGINT ); C;}
  123.  
  124.  
  125.  
  126. {******************************************************************************
  127. *    The function "fegetexcept" stores a representation of the exception       *
  128. *     flags indicated by the argument "excepts" through the pointer argument   *
  129. *     "flagp".                                                                 *
  130. ******************************************************************************}
  131.  
  132. {PROCEDURE fegetexcept( VAR flagp:    fexcept_t;
  133.                         excepts:    LONGINT ); C;}
  134.  
  135.  
  136.  
  137. {******************************************************************************
  138. *     The function "feraiseexcept" raises the supported exceptions             *
  139. *     represented by its argument.                                             *
  140. ******************************************************************************}
  141.  
  142. {PROCEDURE feraiseexcept( excepts:    LONGINT ); C;}
  143.  
  144.  
  145.  
  146. {******************************************************************************
  147. *     The function "fesetexcept" sets or clears the exception flags indicated  *
  148. *     by the int argument "excepts" according to the representation in the     *
  149. *     object pointed to by the pointer argument "flagp".  The value of         *
  150. *     "*flagp" must have been set by a previous call to "fegetexcept".         *
  151. *     This function does not raise exceptions; it just sets the state of       *
  152. *     the flags.                                                               *
  153. ******************************************************************************}
  154.  
  155. {PROCEDURE fesetexcept( VAR flagp:  fexcept_t; excepts:    LONGINT ); C;}
  156.  
  157.  
  158.  
  159. {******************************************************************************
  160. *     The function "fetestexcept" determines which of the specified subset of  *
  161. *     the exception flags are currently set.  The argument "excepts" specifies *
  162. *     the exception flags to be queried as a bitwise OR of the exception       *
  163. *     macros.  This function returns the bitwise OR of the exception macros    *
  164. *     corresponding to the currently set exceptions included in "excepts".     *
  165. ******************************************************************************}
  166.  
  167. {FUNCTION fetestexcept( excepts: LONGINT ): LONGINT; C;}
  168.  
  169.  
  170.  
  171. {******************************************************************************
  172. *     The following functions provide control of rounding direction modes.     *
  173. ******************************************************************************}
  174.  
  175. {******************************************************************************
  176. *     The function "fegetround" returns the value of the rounding direction    *
  177. *     macro which represents the current rounding direction.                   *
  178. ******************************************************************************}
  179.  
  180. {FUNCTION fegetround: LONGINT; C;}
  181.  
  182.  
  183.  
  184. {******************************************************************************
  185. *     The function "fesetround" establishes the rounding direction represented *
  186. *     by its argument.  It returns nonzero if and only if the argument matches *
  187. *     a rounding direction macro.  If not, the rounding direction is not       *
  188. *     changed.                                                                 *
  189. ******************************************************************************}
  190.  
  191. {FUNCTION fesetround(round: LONGINT): LONGINT; C;}
  192.  
  193.  
  194. {******************************************************************************
  195. *    The following functions manage the floating-point environment, exception  *
  196. *    flags and dynamic modes, as one entity.                                   *
  197. ******************************************************************************}
  198.  
  199. {******************************************************************************
  200. *     The function "fegetenv" stores the current floating-point environment    *
  201. *     in the object pointed to by its pointer argument "envp".                 *
  202. ******************************************************************************}
  203.  
  204. {PROCEDURE fegetenv( VAR envp:    fenv_t ); C;}
  205.  
  206.  
  207.  
  208. {******************************************************************************
  209. *     The function "feholdexcept" saves the current environment in the object  *
  210. *     pointed to by its pointer argument "envp", clears the exception flags,   *
  211. *     and clears floating-point exception enables.  This function supersedes   *
  212. *     the SANE function "procentry", but it does not change the current        *
  213. *     rounding direction mode.                                                 *
  214. ******************************************************************************}
  215.  
  216. {FUNCTION feholdexcept( VAR envp: fenv_t ): LONGINT; C;}
  217.  
  218.  
  219.  
  220. {******************************************************************************
  221. *     The function "fesetenv" installs the floating-point environment          *
  222. *     environment represented by the object pointed to by its argument         *
  223. *     "envp".  The value of "*envp" must be set by a call to "fegetenv" or     *
  224. *     "feholdexcept", by an implementation-defined macro of type "fenv_t",     *
  225. *     or by the use of the pointer macro FE_DFL_ENV as the argument.           *
  226. ******************************************************************************}
  227.  
  228. {PROCEDURE fesetenv( VAR envp: fenv_t ); C;}
  229.  
  230.  
  231.  
  232. {******************************************************************************
  233. *     The function "feupdateenv" saves the current exceptions into its         *
  234. *     automatic storage, installs the environment represented through its      *
  235. *     pointer argument "envp", and then re-raises the saved exceptions.        *
  236. *     This function, which supersedes the SANE function "procexit", can be     *
  237. *     used in conjunction with "feholdexcept" to write routines which hide     *
  238. *     spurious exceptions from their callers.                                  *
  239. ******************************************************************************}
  240.       
  241. {PROCEDURE feupdateenv( VAR envp: fenv_t ); C;}
  242.  
  243. {$IFC GENERATING68K}
  244.  
  245. {******************************************************************************
  246. *     The following functions provide control of rounding precision.           *
  247. *     Because the PowerPC does not provide this capability, these functions    *  
  248. *     are available only for the 68K Macintosh.  Rounding precision values     *
  249. *     are defined by the rounding precision macros.  These functions are       *
  250. *     equivalent to the SANE functions getprecision and setprecision.          *
  251. ******************************************************************************}
  252.  
  253. {FUNCTION fegetprec: LONGINT; C;}
  254. {FUNCTION fesetprec (precision: LONGINT): LONGINT; C;}
  255.  
  256. {$ENDC}
  257.  
  258.  
  259. {$ENDC} {__FPENV__}
  260.  
  261.  IMPLEMENTATION
  262.  END.
  263.  
  264.